{% extends '__layout_3col.html' %}
{% block pageTitle %}{% parent %} - Категории задач{%endblock%}
{% block mainLayoutJsInclude %}<script type="text/javascript" src="/js/company-settings-task-categories.js"></script>{%endblock%}

{% block layoutLeftColumn %}
    {% include '_left_menu_company_settings.html' %}
{% endblock %}


{% block layoutCenterColumn %}
    <div class="block">
        <h2>Категории задач</h2>
        {% if taskCategoryEdit %}
          <div>{{taskCategoryEdit}}</div><br />
        {% endif %}
        <div>
            <form id="task-category-edit-form" action="" method="post">
            {{error.show(USER_ERRORS, 'editTaskCategoryError')}}
            <table class="gridTable">
              <thead>
                <tr>
                  <th>№</th>
                  <th>Метка</th>
                  <th>Описание</th>
                  <th>Цена</th>
                  <th>Отчетность</th>
                  <th>Действия</th>
                </tr>
              </thead>
              <tbody id="task-category-show-tbody">
              {% for category in taskCategoryShow %}
                <tr>
                  <td>{{loop.index}}</td>
                  <td>{{ category.data.category_label|e }}<input type="hidden" value="{{ category.data.category_label|e }}" /></td>
                  <td>{{ category.data.task_category_name|e }}<input type="hidden" value="{{ category.data.task_category_name|e }}" /></td>
                  <td>{{ category.data.price_value|e }}<input type="hidden" value="{{ category.data.price_value|e }}" /></td>
                  <td>{% if category.data.is_reportable %}Да{% else %}Нет{% endif %}<input type="hidden" value="{{ category.data.is_reportable|e }}" /></td>
                  <td>
                    <!-- a href="#" class="" onclick="editTaskCategory('{{ category.data.task_category_id|e }}');">Редактировать</a><br / -->
                    <a href="#" class="tc-edit-link" id="{{ category.data.task_category_id|e }}">Редактировать</a><br />
                    <a href="#" onclick="if(confirm('Вы действительно хотите удалить категорию задач?')){deleteTaskCategory('{{ category.data.task_category_id|e }}');}">Удалить</a>
                  </td>
                </tr>
              {% endfor %}
              </tbody>
              <tfoot>
                <tr>
                  <th>&nbsp;</th>
                  <th><input id="tc-add-label" type="text" value="{% if REQUEST.action=='add' %}{% if not taskCategoryEdit %}{{ REQUEST.label }}{% endif %}{% endif %}" /></th>
                  <th><input id="tc-add-name" type="text" value="{% if REQUEST.action=='add' %}{% if not taskCategoryEdit %}{{ REQUEST.name }}{% endif %}{% endif %}" /></th>
                  <th><input id="tc-add-price" type="text" value="{% if REQUEST.action=='add' %}{% if not taskCategoryEdit %}{{ REQUEST.price }}{% endif %}{% endif %}" size="4" /></th>
                  <th><input id="tc-add-report" type="checkbox" value="1" {% if REQUEST.action=='add' %}{% if not taskCategoryEdit %}{% if REQUEST.report %}checked{% endif %}{% else %}checked{% endif %}{% else %}checked{% endif %} /></th>
                  <th><input type="button" value="Добавить" onclick="addTaskCategory();" /></th>
                </tr>
              </tfoot>
            </table>
            </form>
            {{error.show(USER_ERRORS, 'addTaskCategoryError')}}
            
            <div style="display: none;">
              <form id="task-category-delete-form" action="" method="post">
                <input type="hidden" name="action" value="delete" />
                <input type="hidden" id="task-category-delete-uuid" name="uuid" value="" />
              </form>
              <form id="task-category-add-form" action="" method="post">
                <input type="hidden" name="action" value="add" />
                <input type="hidden" id="task-category-add-name" name="name" value="" />
                <input type="hidden" id="task-category-add-label" name="label" value="" />
                <input type="hidden" id="task-category-add-price" name="price" value="" />
                <input type="hidden" id="task-category-add-report" name="report" value="" />
              </form>
              <table>
                <tbody id="task-category-edit-tbody">
                  <tr id="task-category-edit-tr">
                    <td><input type="hidden" name="action" value="edit" /><input type="hidden" id="task-category-edit-uuid" name="uuid" value="" />&nbsp;</td>
                    <td><input type="text" id="task-category-edit-label" name="label" value="" /></td>
                    <td><input type="text" id="task-category-edit-name" name="name" value="" /></td>
                    <td><input type="text" id="task-category-edit-price" name="price" value="" /></td>
                    <td><input type="checkbox" id="task-category-edit-report" name="report" value="1" /></td>
                    <td><input type="submit" id="task-category-edit-submit" value="Сохранить" /></td>
                  </tr>
                </tbody>
              </table>
            </div>
        </div>
    </div>
{% endblock %}

